package org.example.im.client.handler;

import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.SimpleChannelInboundHandler;
import org.example.im.bean.protocol.response.JoinGroupResponsePacket;
import org.springframework.stereotype.Component;

/**
 * @author dingrui
 * @since 2022/2/12
 * @description 加入群聊
 */
@Component
public class JoinGroupHandler extends SimpleChannelInboundHandler<JoinGroupResponsePacket> {

    @Override
    protected void channelRead0(ChannelHandlerContext channelHandlerContext, JoinGroupResponsePacket joinGroupResponsePacket) throws Exception {
        String groupId = joinGroupResponsePacket.getGroupId();
        if (joinGroupResponsePacket.isSuccess()) System.out.println("[C-JoinGroup]加入群[" + groupId + "]成功");
        else System.out.println("[C-JoinGroup]加入群[" + groupId + "]失败 详情:" + joinGroupResponsePacket.getMsg());
    }
}
